package cn.com.wxd.service.scheduledtask;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import cn.com.wxd.service.sms.SmsInfo;
import cn.com.wxd.service.sms.SmsSentFactor;
import cn.com.wxd.service.weather.WeatherService;
import cn.com.wxd.common.DateUtil;

/**
 * Title:ServicesTimeTask.java
 * Description:cn.com.wxd.service.scheduledtask
 * 
 * Company: Amumu管理平台
 * Copyright: Copyright (c) 2015
 * All right reserved.
 * Created time: 2016-5-11 上午10:30:33
 *
 * @author WangXuDong
 * @version 1.0
 */
public class ServicesTimeTask {
	private static final Logger log = LoggerFactory.getLogger(ServicesTimeTask.class);
	/**
	 * 天气定时更新
	 */
	public void weatherService() {
		try {
			WeatherService.upDateWheather();//发送请求获取天气信息
            log.info("时间："+DateUtil.getDatetimeStr()+",天气数据已经更新！");
		} catch (Exception e) {
            log.error("天气更新失败，检查网络连接"+e.getMessage(),e);
		}
	}
	/**
	 * 短信余额检测
	 */
	public void smsService(){
		//验证短信验证码的余额
		int num = SmsSentFactor.getSenter().queryBalance();
		try {
			SmsInfo.setSmsBalance(num);
			log.info("时间："+DateUtil.getDatetimeStr()+"短信剩余条数为:"+num+" 条,短信服务:"+SmsInfo.getDefaultService());
			if(num<=50){
				log.warn("短信剩余条数太少！请及时充值!充值服务为:"+SmsInfo.getDefaultService());
			}
		} catch (Exception e) {
			log.error("短信余额查询失败!"+e.getMessage(),e);
		}
		
		
	}
}
